package com.woniuxy.dudugua.service.impl;

import com.woniuxy.dudugua.entity.ProductScan;
import com.woniuxy.dudugua.mapper.ProductScanMapper;
import com.woniuxy.dudugua.service.ProductScanService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ProductScanServiceImpl implements ProductScanService {
    @Resource
    private ProductScanMapper productScanMapper;
    /**
     * 传入一个用户id，查询该用户的浏览历史
     * @param userId
     * @return
     * @throws Exception
     */
    public List<ProductScan> selectScan(Integer userId) throws Exception {
        List<ProductScan> productScans = productScanMapper.selectScan(userId);
        return productScans;
    }

    @Override
    public List<ProductScan> selectByProductId(Integer id) {
        return productScanMapper.selectByProductId(id);
    }

    @Override
    public ProductScan selectScanById(Integer productId, Integer userId) {
        return productScanMapper.selectScanById(productId,userId);
    }

    @Override
    public int updateScan(ProductScan productScan) {
        return productScanMapper.updateByPrimaryKey(productScan);
    }

    @Override
    public int insertScan(ProductScan productScan) {
        return productScanMapper.insert(productScan);
    }
}
